<%@include file="include/head.jsp" %>
<wml>
    <card title="${sent?'Sent Messages':'Recvied Messages'} - Pechapai" id="main">
        Welcome ${user}. API: ${rateLimitStatus.remainingHits}/${rateLimitStatus.hourlyLimit}
        <strong>${message}</strong>
        <c:forEach items="${messages}" var="msg">
            <p>
                <a href="<c:out value="${BASE_URL}/timeline.wml?timeline=user&name=${sent?msg.recipient.screenName:msg.sender.screenName}" escapeXml="true"/>">${sent?msg.recipient.screenName:msg.sender.screenName}</a>: <c:out value="${msg.text}" escapeXml="true"/> <br/>
                ${msg.createdAt}
                <c:if test="${sent}">
                    <a href="<c:out value="${BASE_URL}/dm.wml?action=new&name=${msg.sender.screenName}" escapeXml="true"/>">Reply</a>
                </c:if>
            </p>
        </c:forEach>
        <do name="prev_page" type="option" label="Prev Page">
            <go href="<c:out value="${BASE_URL}/dm.wml?sent=${sent}" escapeXml="true"/>" method="get">
                <postfield name="page" value="${page!=1?page-1:1}"/>
            </go>
        </do>
        <do name="next_page" type="option" label="Next Page">
            <go href="<c:out value="${BASE_URL}/dm.wml?sent=${sent}" escapeXml="true"/>" method="get">
                <postfield name="page" value="${page+1}"/>
            </go>
        </do>
        <do name="sent" type="option" label="Sent Message">
            <go href="<c:out value="${BASE_URL}/dm.wml?sent=true" escapeXml="true"/>" method="get">
                <postfield name="page" value="1"/>
            </go>
        </do>
        <do name="recv" type="option" label="Recived Message">
            <go href="<c:out value="${BASE_URL}/dm.wml?sent=false" escapeXml="true"/>" method="get">
                <postfield name="page" value="1"/>
            </go>
        </do>
        <do type="accept" label="New Message">
            <go href="${BASE_URL}/dm.wml?action=new"/>
        </do>
        <do type="option" label="Menu">
            <go href="#menu"/>
        </do>
    </card>
    <%@include file="include/menu.jsp" %>
</wml>
